function setQueryString(key, value) {
	var url = window.location.href;
	var len ;
	//alert("url:" + url);
	
	var uri = url;
	var query = "";
	var idx = url.indexOf("?");
	if (idx > -1) {
		uri = url.substring(0, idx);
		query = url.substring(idx + 1);
	}
	//�����#�ŵ�ȥ��
	len = query.indexOf("#");
	if(len>-1){
		query = query.substring(0,len);
	}
	
//	var idx1 = query.indexOf("delete");
	
//	if(idx1>-1){
//		query = query.substring(0,idx1);
//		query = query+"list";
//	}
	
	//alert("uri:" + uri);
	//alert("query:" + query);
	
	var newQuery = "";
	var params = query.split("&");
	var isNotFirst = false;
	//alert("length:" + params.length);
	for (var i = 0; i < params.length; i = i + 1) {
		//alert("params[" + i + "]:" + params[i]);
		if (params[i] != "" && params[i].indexOf(key) == -1) {
			if (isNotFirst) {
				newQuery = newQuery + "&";
			}
			newQuery = newQuery + params[i];
			isNotFirst = true;
		}
	}
	if (isNotFirst) {
		newQuery = newQuery + "&";
	} 

	if (value == currentPage || value > totalPage || value < 1) { 
 		if(event.keyCode==13){
 			newQuery = newQuery + key + "=" + 1;
 		}else return;
 	}else  	newQuery = newQuery + key + "=" + value;
	
	newUrl = uri + "?" + newQuery;
 	 
 	//alert(newUrl);
	document.forms[0].action=newUrl;
	document.forms[0].submit(); 
	//window.location.href = newUrl;
}

function gotoPage(pageIndex) {   
	//if (pageIndex == currentPage || pageIndex > totalPage || pageIndex < 1) {
		//return;
	//}
	//alert("gotoPage start!");
	setQueryString("pageIndex", pageIndex);
}

function beforeScrollIndex() {
	if (beginPage <= 1) {
		return ;
	}
	beginPage = beginPage - 10;
	processScrollIndex();
	if (beginPage <= 1) {
		document.getElementById("pageBefore").style.cursor = "default";
	} else {
		document.getElementById("pageBefore").style.cursor = "pointer";
	}
}

function afterScrollIndex() {
	if (beginPage >= totalPage - 10) {
		return ;
	}
	beginPage = beginPage + 10;
	processScrollIndex();
	if (beginPage >= totalPage - 10) {
		document.getElementById("pageAfter").style.cursor = "default";
	} else {
		document.getElementById("pageAfter").style.cursor = "pointer";
	}
}

function processScrollIndex() {
	for (var i = 1; i <= 10; i = i + 1) {
		var pageIndexId = "pageIndex" + i;
		var pageSeparatorId = "pageSeparator" + i;
		var pageIndex = beginPage + i - 1;
		if (pageIndex > totalPage) {
			document.getElementById(pageIndexId).style.display = "none";
			if (i > 1) {
				document.getElementById(pageSeparatorId).style.display = "none";
			}
		} else {
			if (pageIndex == currentPage) {
				document.getElementById(pageIndexId).style.color = "red";
				document.getElementById(pageIndexId).style.cursor = "default";
			} else {
				document.getElementById(pageIndexId).style.color = "black";
				document.getElementById(pageIndexId).style.cursor = "pointer";
			}
			document.getElementById(pageIndexId).innerText = "" + pageIndex;
			document.getElementById(pageIndexId).style.display = "";
			if (i > 1) {
				document.getElementById(pageSeparatorId).style.display = "";
			}
		}
	}
}
